<%@page import="entities.OrderEntity"%>
<%@page import="service.OrderService"%>
<%@page import="service.SellerService"%>
<%@page import="entities.SellerEntity"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

	String sellerName = (String) session.getAttribute("sellerName");
	String password = (String) session.getAttribute("sellerpassword");
	SellerEntity seller = new SellerEntity();
	if (sellerName == null || password == null) {
		response.sendRedirect("index.jsp");
	} else {
		seller = SellerService.confirm(sellerName, password.trim());
	}
	String date = request.getParameter("date");
	String[] totleDate = new String[6];
	String[] monthYear = date.split("-");
	totleDate[0] = monthYear[0]+"-"+monthYear[1];
	for(int i=1;i<6;i++){
	if(Integer.parseInt(monthYear[1])-i>0 && Integer.parseInt(monthYear[1])-i<10){
		Integer i1 = Integer.parseInt(monthYear[1]) - i;
		String month1 = "0"+i1;
		totleDate[i] = monthYear[0]+"-"+month1;
	}else if(Integer.parseInt(monthYear[1])-i<=0 && Integer.parseInt(monthYear[1])-i>-3){
		Integer i2 = Integer.parseInt(monthYear[1]) - i + 12 ;
		String year1 = String.valueOf(Integer.parseInt(monthYear[0]) - 1);
		totleDate[i] = year1+"-"+i2;
	}else if(Integer.parseInt(monthYear[1])-i>=10){
		Integer i3 = Integer.parseInt(monthYear[1]) - i;
		totleDate[i] = monthYear[0]+"-"+i3;
	}else if(Integer.parseInt(monthYear[1])-i<=-3){
		Integer i4 = Integer.parseInt(monthYear[1]) - i + 12 ;
		String month2 = "0"+i4;
		String year2 = String.valueOf(Integer.parseInt(monthYear[0]) - 1);
		totleDate[i] = year2+"-"+month2;
	}
	
	}
%>

<!DOCTYPE HTML>
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>销售统计</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="<%=basePath%>_seller/js/grid.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/jquery.min.js"></script>
	<script language="javascript"> 
		function startTime() 
		{ 
		var today=new Date(); 
		var y=today.getFullYear(); 
		var m=today.getMonth() + 1; 
		//add a zero in front of number<10 
		//m = checkTime(m);
		for(var i = 0;i<6;i++){
		if((m-i)>0){
		var n = m-i;
		document.getElementById("now_"+i).innerHTML = y + "-" + n;
		}else if((m-i)<=0){
		var n = m-i+12;
		var y1 = y - 1;
		document.getElementById("now_"+i).innerHTML = y1 + "-" + n;
		
		}
		} 
		}
		function checkTime(i) 
		{ 
		if (i<10) 
		{ 
		i="0"+i; 
		} 
		return i; 
		} 
	</script> 

	<style type="text/css">
	
	table#grid {
	width: 1000px;
	margin: auto;
	empty-cells: show;
	border-collapse: collapse;
	border-spacing: 0;
	empty-cells: show;
	margin: auto;
}

#grid td,#grid th {
	padding: 5px;
	border: #E3E3E3 1px solid;
	font-size: 13px;
	height: 16px;
	line-height: 16px;
}

#grid tr th {
	color: #ff0000;
	background-color: #ffffcc;
	font-size: 16px;
	font-weight: bold;
	padding: 8px 0px;
}
	</style>
  </head>
  
  <body>
  	<jsp:include page="header.jsp"></jsp:include>
  
  <div style="text-align: center;">
  	<table id="grid" style=" margin: auto;marin-top:30px;">
  		<tr style="height:30px;"><td style="width:100px;"><span><%=totleDate[0] %></span></td><td style="height:30px;width:500px;"><%=SellerService.getSellerCount(totleDate[0],seller.getId()+"") %></td><td><a href="<%=basePath%>_seller/dealdetail.jsp?date=<%=totleDate[0]%>">详情</a></td></tr>
  		<tr style="height:30px;"><td style="width:100px;"><span><%=totleDate[1] %></span></td><td style="height:30px;width:500px;"><%=SellerService.getSellerCount(totleDate[1],seller.getId()+"") %></td><td><a href="<%=basePath%>_seller/dealdetail.jsp?date=<%=totleDate[1]%>">详情</a></td></tr>
  		<tr style="height:30px;"><td style="width:100px;"><span><%=totleDate[2] %></span></td><td style="height:30px;width:500px;"><%=SellerService.getSellerCount(totleDate[2],seller.getId()+"") %></td><td><a href="<%=basePath%>_seller/dealdetail.jsp?date=<%=totleDate[2]%>">详情</a></td></tr>
  		<tr style="height:30px;"><td style="width:100px;"><span><%=totleDate[3] %></span></td><td style="height:30px;width:500px;"><%=SellerService.getSellerCount(totleDate[3],seller.getId()+"") %></td><td><a href="<%=basePath%>_seller/dealdetail.jsp?date=<%=totleDate[3]%>">详情</a></td></tr>
  		<tr style="height:30px;"><td style="width:100px;"><span><%=totleDate[4] %></span></td><td style="height:30px;width:500px;"><%=SellerService.getSellerCount(totleDate[4],seller.getId()+"") %></td><td><a href="<%=basePath%>_seller/dealdetail.jsp?date=<%=totleDate[4]%>">详情</a></td></tr>
  		<tr style="height:30px;"><td style="width:100px;"><span><%=totleDate[5] %></span></td><td style="height:30px;width:500px;"><%=SellerService.getSellerCount(totleDate[5],seller.getId()+"") %></td><td><a href="<%=basePath%>_seller/dealdetail.jsp?date=<%=totleDate[5]%>">详情</a></td></tr>
  	</table>
  </div> 
  </body>
</html>
